package com.cn.lyl.servlet.service.type;

import com.alibaba.fastjson.JSONObject;
import com.cn.lyl.model.ServiceTypeModel;
import com.cn.lyl.service.ServiceTypeService;
import com.cn.lyl.service.impl.NewsTypeServiceImpl;
import com.cn.lyl.service.impl.ServiceTypeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/back/service/type/all")
public class FindAllTypeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        ServiceTypeService serviceTypeService = new ServiceTypeServiceImpl();
        List<ServiceTypeModel> all = serviceTypeService.findAll();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("types",all);
        for (ServiceTypeModel typeModel :all){
            System.out.println(typeModel.getType());
        }
        resp.getWriter().print(jsonObject);
    }
}
